![]() |
PBLockRangeAsync |
||||
Header: | Files.h | Carbon status: | Supported | |
Locks a portion of a file.
OSErr PBLockRangeAsync ( ParmBlkPtr paramBlock );
A pointer to a basic File Manager parameter block.
A result code.
The relevant fields of the parameter block are:
On input, a pointer to a completion function.
On output, the result code of the function.
On input, the file reference number
On input, the number of bytes in the range.
On input, the positioning mode.
On input, the positioning offset.
The PBLockRangeAsync function locks a portion of a file that was opened with shared read/write permission. The beginning of the range to be locked is determined by the ioPosMode and ioPosOffset fields. The end of the range to be locked is determined by the beginning of the range and the ioReqCount field. For example, to lock the first 50 bytes in a file, set ioReqCount to 50, ioPosMode to fsFromStart, and ioPosOffset to 0. Set ioReqCount to –1 to lock the maximum number of bytes from the position specified in ioPosOffset.
The PBLockRangeAsync function uses the same parameters as both PBReadAsync and PBWriteAsync; by calling it immediately before PBRead, you can use the information in the parameter block for the PBRead call.
When you’re finished with the data (typically after a call to PBWriteAsync), be sure to call PBUnlockRangeAsync to free that portion of the file for subsequent PBReadAsync calls.
The PBLockRangeAsync function does nothing if the file specified in the ioRefNum field is open with shared read/write permission but is not located on a remote server volume or is not located under a share point on a sharable local volume.
In system software versions 6.0.7 and earlier, specifying ioPosMode as fsFromLEOF results in the wrong byte range being locked.
Supported in Carbon. Available in Mac OS 8.1 and later when Carbon 1.0.2 or later is present.
© 2000 Apple Computer, Inc. — (Last Updated 5/8/2000)